package 面向对象初级.封装.封装的实现;

public class Book {
    /*
    练习2：
    自定义图书类。设定属性包括：书名bookName，作者author，
    出版社名publisher，价格price；方法包括：相应属性的get/set方法，图书信息介绍等。
     */
    private String bookName;
    private String author;
    private String publisher;
    private double price;

    //无参构造器
    public Book() {
    }

    //有参构造器
    public Book(String bookName, String author, String publisher, double price) {
        this.bookName = bookName;
        this.author = author;
        this.publisher = publisher;
        this.price = price;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getPublisher() {
        return publisher;
    }

    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    //返回图书对象的所有信息，重写得到的

    @Override
    public String toString() {
        return "book{" +
                "bookName='" + bookName + '\'' +
                ", author='" + author + '\'' +
                ", publisher='" + publisher + '\'' +
                ", price=" + price +
                '}';
    }
}
